# -*- coding: utf-8 -*-

"""
Module implementing m2etabs97.
"""
from PyQt4 import  QtGui
#from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui import QDialog

from Ui_m2e import Ui_m2etabs97


class m2etabs97(QDialog, Ui_m2etabs97):
    """
    Class documentation goes here.
    """
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)
        
        self.le_wjm.textChanged[str].connect(self.lewjmchanged)
        self.pb_yes.clicked.connect(self.m2etrans)
    
    def lewjmchanged(self, text):        
        self.wjmf=text
        print(self.wjmf)
    
#读入变量统计：
#self.mversion-版本号
#
#

    
    def m2etrans(self):
        self.wjmf='Midas_Pkpm.mgt'
        self.wjmt='1.e2k'
#打开文件名读入，同时打开'1.mgt'写入，用于比较是否正确读入
        
        f=open(self.wjmf, 'r')
        f1=open('1.mgt', 'w')

#定义节点字典样式示例
        mnd={'nnum':0, 'x':0, 'y':0, 'z':0}
#定义节点列表
        mnode=[]
#定义截面的字典样式示例，多种截面都放在一起，除了参数复杂的钢骨混凝土
        msec={'snum':0, 'sectiontype':'0','sname':'0','soffsec':'CC','sb':0, 'sh':0, 'sr':0, 'epct':0}
#定义截面的列表
        msection=[]
#定义墙、板厚度列表
        mtk={'thicknum':0, 'thickness':0}
        mthick=[]
#定义材料的列表
        mmat=[]        
#定义单元的列表
        mele=[]            
#定义释放的列表
        mframerelease=[]  
#定义静荷载工况列表  
        mstldcase=[]
#定义静荷载列表  
        mstld=[]


#循环读入，空格则跳过
        while True:
            line=f.readline()
#若结尾则退出            
            if not line:
                break
#空行则跳过                
            if not line.strip():
                continue

 #如是版本信息，则读入
            if(line.find('VERSION')>=0):
                self.mversion=f.readline()
                f1.write(line)
                f1.write(self.mversion)
#如是单位信息，则读入
            if(line.find('UNIT')>=0):
                self.munit=f.readline()
                f1.write(line)
                f1.write(self.munit)
#如是节点信息，则循环读入，每个节点信息添加到列表mnode中去，读到空行则表示结束
            if(line.find('NODE')>=0):
                f1.write(line)
                while True:
                    nodeline=f.readline()
                    #空行则结束                
                    if not nodeline.strip():
                        break
                    #去掉空格                    
                    ninfo="".join(nodeline.split()) 
                    ninfo=ninfo.split(',')
                    mnd={'nnum':ninfo[0], 'x':ninfo[1], 'y':ninfo[2], 'z':ninfo[3]}
                    mnode.append(mnd)         
                    #输出到f1文件做对比
                    f1node=(mnode[-1]['nnum'], mnode[-1]['x'], mnode[-1]['y'], mnode[-1]['z'])
                    f1.write(','.join(f1node)+'\n')
                    
#如是截面信息，则循环读入，每个截面信息添加到列表msection中去，读到空行则表示结束
            if(line.find('SECTION')>=0):
                f1.write(line)
                while True:
                    sectionline=f.readline()
                    #空行则结束                
                    if not sectionline.strip():
                        break
                    #去掉空格                    
                    secinfo="".join(sectionline.split()) 
                    secinfo=secinfo.split(',')
                    
                    #分类存储截面信息
                    #1. 矩形截面dbuser中矩形截面
                    if(sectionline.find('DBUSER')>=0 and sectionline.find('SB')>=0 ):
                        msec={'snum':secinfo[0], 'sectiontype':'Rectangular','sname':secinfo[2],'soffsec':secinfo[3],'sb':secinfo[14], 'sh':secinfo[13]}
                        msection.append(msec)         
                        #输出到f1文件做对比
                        f1sec=(msection[-1]['snum'], msection[-1]['sectiontype'], msection[-1]['sname'], msection[-1]['soffsec'], msection[-1]['sb'], msection[-1]['sh'])
                        f1.write(','.join(f1sec)+'\n')
                    #2. 圆形截面
                    if(sectionline.find('DBUSER')>=0 and sectionline.find('SR')>=0 ):
                        msec={'snum':secinfo[0], 'sectiontype':'Circle','sname':secinfo[2],'soffsec':secinfo[3],'sr':secinfo[13]}
                        msection.append(msec)         
                        #输出到f1文件做对比
                        f1sec=(msection[-1]['snum'], msection[-1]['sectiontype'], msection[-1]['sname'], msection[-1]['soffsec'], msection[-1]['sr'])
                        f1.write(','.join(f1sec)+'\n')                    
                    #2. 钢管柱截面，要再多读一行数据
                    if(sectionline.find('SRC')>=0 and sectionline.find('EPC')>=0 ):
                        #第一行读截面编号和名称
                        msec={'snum':secinfo[0], 'sectiontype':'GangGuanZhu','sname':secinfo[2],'soffsec':secinfo[3]}
                        #第二行读外径和壁厚
                        sectionline=f.readline()     
                        #去掉空格                    
                        secinfo="".join(sectionline.split()) 
                        secinfo=secinfo.split(',')      
                        msec['sr']=secinfo[3]
                        msec['st']=secinfo[4]
                        msection.append(msec)         
                        #输出到f1文件做对比
                        f1sec=(msection[-1]['snum'], msection[-1]['sectiontype'], msection[-1]['sname'], msection[-1]['soffsec'], msection[-1]['sr'], msection[-1]['st'])
                        f1.write(','.join(f1sec)+'\n')   
                        
#如是墙、板厚度信息，则循环读入，每个截面信息添加到列表mthickness中去，读到空行则表示结束
            if(line.find('THICKNESS')>=0):
                f1.write(line)
                while True:
                    thickline=f.readline()
                    #空行则结束                
                    if not thickline.strip():
                        break
                    #去掉空格                    
                    thickinfo="".join(thickline.split()) 
                    thickinfo=thickinfo.split(',')
                    
                    #存储厚度信息   
                    mtk={'thicknum':thickinfo[0], 'thickness':thickinfo[3]}
                    mthick.append(mtk)
                    f1thick=(mthick[-1]['thicknum'], mthick[-1]['thickness'])
                    f1.write(','.join(f1thick)+'\n')           
                    
#如是墙材料信息，则循环读入，每个材料信息添加到列表mmat中去，读到空行则表示结束
#组合截面有钢和砼2种材料， Midas定义为1种新材料
            if(line.find('MATERIAL')>=0):
                f1.write(line)
                while True:
                    matline=f.readline()
                    #空行则结束                
                    if not matline.strip():
                        break
                    #去掉空格                    
                    matinfo="".join(matline.split()) 
                    matinfo=matinfo.split(',')
                    
                    #存储材料信息   
                     #1. 混凝土材料
                    if(matline.find('CONC')>=0):                   
                        mt={'matnum':matinfo[0], 'mattype':matinfo[1], 'matname':matinfo[2]}
                        mmat.append(mt)
                        f1mat=(mmat[-1]['matnum'], mmat[-1]['mattype'], mmat[-1]['matname'])
                        f1.write(','.join(f1mat)+'\n')      
                     #2. 组合截面的材料, 要再多读一行数据
                    if(matline.find('SRC')>=0):      
                        #第一行读材料编号、名称和钢材强度
                        mt={'matnum':matinfo[0], 'mattype':matinfo[1], 'matname':matinfo[2], 'steel':matinfo[11]}
                        #第二行读砼强度
                        matline=f.readline()     
                        #去掉空格                    
                        matinfo="".join(matline.split()) 
                        matinfo=matinfo.split(',')      
                        mt['conc']=matinfo[3]
                        mmat.append(mt)
                        f1mat=(mmat[-1]['matnum'], mmat[-1]['mattype'], mmat[-1]['matname'], mmat[-1]['steel'], mmat[-1]['conc'])
                        f1.write(','.join(f1mat)+'\n')                        
#如是单元信息，则循环读入，每个单元信息添加到列表melement中去，读到空行则表示结束
            if(line.find('ELEMENT')>=0):
                f1.write(line)
                while True:
                    eleline=f.readline()
                    #空行则结束                
                    if not eleline.strip():
                        break
                    #去掉空格                    
                    eleinfo="".join(eleline.split()) 
                    eleinfo=eleinfo.split(',')
                    
                    #存储单元信息   
                     #1. beam单元
                    if(eleline.find('BEAM')>=0):                   
                        ele={'elenum':eleinfo[0], 'eletype':eleinfo[1], 'elemat':eleinfo[2], 'elesection':eleinfo[3], 'eleI':eleinfo[4], 'eleJ':eleinfo[5]}
                        mele.append(ele)
                        f1ele=(mele[-1]['elenum'], mele[-1]['eletype'], mele[-1]['elemat'], mele[-1]['elesection'], mele[-1]['eleI'], mele[-1]['eleJ'])
                        f1.write(','.join(f1ele)+'\n')      
                     #2. 平面单元,wall/plate，wall是4节点，plate是3节点
                    if(eleline.find('WALL')>=0 or eleline.find('PLATE')>=0):                   
                        ele={'elenum':eleinfo[0], 'eletype':eleinfo[1], 'elemat':eleinfo[2], 'elesection':eleinfo[3], 'eleI':eleinfo[4], 'eleJ':eleinfo[5] ,'eleK':eleinfo[6] ,'eleL':eleinfo[7]}
                        mele.append(ele)
                        f1ele=(mele[-1]['elenum'], mele[-1]['eletype'], mele[-1]['elemat'], mele[-1]['elesection'], mele[-1]['eleI'], mele[-1]['eleJ'], mele[-1]['eleK'], mele[-1]['eleL'])
                        f1.write(','.join(f1ele)+'\n')      
#如是梁端释放信息，则循环读入，每个单元信息添加到列表mbeamrelease中去，读到空行则表示结束
            if(line.find('FRAME-RLS')>=0):
                f1.write(line)
                while True:
                    #读第一行I端释放
                    line1=f.readline()
                    #空行则结束                
                    if not line1.strip():
                        break
                    #去掉空格                    
                    info1="".join(line1.split()) 
                    info1=info1.split(',')
                    #读第二行J端释放
                    line2=f.readline()                    
                    #去掉空格                    
                    info2="".join(line2.split()) 
                    info2=info2.split(',')   
                    #存储释放信息   
                    rele={'elenum':info1[0], 'fxi':info1[2][0], 'fyi':info1[2][1], 'fzi':info1[2][2], 'mxi':info1[2][3], 'myi':info1[2][4], 'mzi':info1[2][5], 
                                                       'fxj':info2[0][0], 'fyj':info2[0][1], 'fzj':info2[0][2], 'mxj':info2[0][3], 'myj':info2[0][4], 'mzj':info2[0][5]}
                    mframerelease.append(rele)
                    f1w=(mframerelease[-1]['elenum'], mframerelease[-1]['fxi'], mframerelease[-1]['fyi'], mframerelease[-1]['fzi'], 
                                                                      mframerelease[-1]['mxi'], mframerelease[-1]['myi'], mframerelease[-1]['mzi'], 
                                                                      mframerelease[-1]['fxj'], mframerelease[-1]['fyj'], mframerelease[-1]['fzj'], 
                                                                      mframerelease[-1]['mxj'], mframerelease[-1]['myj'], mframerelease[-1]['mzj'])
                    f1.write(','.join(f1w)+'\n')      
#如是荷载工况定义信息，则循环读入，每个工况信息添加到列表mstldcase中去，读到空行则表示结束
#文件中; LCNAME, LCTYPE, DESC这行是描述，跳过
            if(line.find('STLDCASE')>=0):
                f1.write(line)
                line=f.readline() #用来跳过“LCNAME, LCTYPE, DESC”这行
                while True:
                    line=f.readline()
                    #空行则结束                
                    if not line.strip():
                        break
                    #去掉空格                    
                    info="".join(line.split()) 
                    info=info.split(',')
                    #存储工况定义信息   
                    mcase={'loadcasename':info[0], 'casetype':info[1]}
                    mstldcase.append(mcase)
                    f1w=(mstldcase[-1]['loadcasename'], mstldcase[-1]['casetype'])
                    f1.write(','.join(f1w)+'\n')  
#依次读入每个工况信息，所有的荷载信息均在一个列表mstld，添加一个字段标志工况名。
#读到空行则表示荷载信息结束，读到"End of data for load case"表示本工况结束。
#文件中; LCNAME, LCTYPE, DESC这行是描述，跳过
            if(line.find('USE-STLD')>=0):
                f1.write(line)
                #去掉空格，读取工况名                  
                info="".join(line.split()) 
                info=info.split(',')  
                casename=info[1]
                while True:
                    line=f.readline()
                    #读到"End of data for load case"表示本工况结束
                    if(line.find('End of data for load case')>=0):
                        break
                    #空行/CONLOAD/BEAMLOAD/PRESSURE则跳过                
                    if(not line.strip()):
                        continue
                    if(line.find('CONLOAD')>=0):
                        loadname='CONLOAD'
                        continue
                    if(line.find('BEAMLOAD')>=0):
                        loadname='BEAMLOAD'
                        continue
                    if(line.find('PRESSURE')>=0):
                        loadname='PRESSURE'
                        continue
                    #如果是荷载信息，去掉空格                    
                    info="".join(line.split()) 
                    info=info.split(',')
                    #分类存储荷载信息
                    #2.梁荷载
                    if(line.find('BEAM')>=0):
                        mload={'loadcasename':casename, 'loadname':loadname, 'beamnumber':info[0], 'loadtarget':info[1],'loadtype':info[2], 
                               'loaddirection':info[3], 'proj':info[4], 
                               'ldposition1':info[10],'ldvalue1':info[11],'ldposition2':info[12],'ldvalue2':info[13], 
                               'ldposition3':info[14],'ldvalue3':info[15],'ldposition4':info[16],'ldvalue4':info[17]}
                    #midas的z方向是向上为正，etabs是向下为正，所以面荷载方向是lz时，要反号                               
                        if mload['loaddirection']=='LZ':
                            mload['ldvalue1']=str((-1)*float(mload['ldvalue1']))      
                            mload['ldvalue2']=str((-1)*float(mload['ldvalue2']))    
                            mload['ldvalue3']=str((-1)*float(mload['ldvalue3']))    
                            mload['ldvalue4']=str((-1)*float(mload['ldvalue4']))    
                            
                        mstld.append(mload)
                        f1w=(mstld[-1]['loadcasename'], mstld[-1]['loadname'], mstld[-1]['beamnumber'], mstld[-1]['loadtype'], 
                            mstld[-1]['loaddirection'], mstld[-1]['proj'], 
                            mstld[-1]['ldposition1'], mstld[-1]['ldvalue1'],mstld[-1]['ldposition2'], mstld[-1]['ldvalue2'],
                            mstld[-1]['ldposition3'], mstld[-1]['ldvalue3'],mstld[-1]['ldposition4'], mstld[-1]['ldvalue4'])
                        f1.write(','.join(f1w)+'\n')  
                    #3.面荷载
                    if(line.find('PRES')>=0):
                        mload={'loadcasename':casename, 'loadname':loadname, 'facenumber':info[0], 'loadtarget':info[2],
                               'facetype':info[2],'loaddirection':info[4], 'proj':info[8],'pressurevalue':info[9]}
                    #midas的z方向是向上为正，etabs是向下为正，所以面荷载方向是lz时，要反号
                        if mload['loaddirection']=='LZ':
                            mload['pressurevalue']=str((-1)*float(mload['pressurevalue']))
                        mstld.append(mload)
                        f1w=(mstld[-1]['loadcasename'], mstld[-1]['loadname'], mstld[-1]['facenumber'], mstld[-1]['facetype'], 
                            mstld[-1]['loaddirection'], mstld[-1]['proj'],mstld[-1]['pressurevalue'])
                        f1.write(','.join(f1w)+'\n')  
        f.close()
        f1.close()
#
#写入etabs文件。
#打开文件名'm2e.e2k'写入        
        f=open('m2e.e2k', 'w')
        #1. 写入程序信息
        f.write('''$ PROGRAM INFORMATION
  PROGRAM  "ETABS"  VERSION "9.7.0"
  
$ CONTROLS
  UNITS  "KN"  "M"  
  TITLE1  "cks"  
  PREFERENCE  MERGETOL 0.01
  RLLF  METHOD "CHINESEGB500092001"   ''' )
        f.write('\n')
#统计所有节点的标高，一个标高一个层
#        estory=[]
#        for node in mnode:
#            if node['z']  in estory:
#                continue
#            elif node['z'] not in estory:
#                estory.append(node['z'])
#        print(estory)


#--------------------------------------
#读入层高信息
        estory=[]
        layer=[]
#        fcg=open('cg.txt', 'r')
#循环读入，空格则跳过
#        while True:
#            line=fcg.readline()
#            print(line)
#若结尾则退出            
#            if not line:
#                break
#            info="".join(line.split()) 
#            info=info.split(',')
#            layer.append({'laynum':info[0], 'layheight':info[1], 'z':info[2]})
#            estory.append(info[2])
#            print(info[0],info[1], info[2])

#方法2
#通过PKPM的WMASS.OUT文件读入层高信息
        fcg=open('WMASS.OUT', 'r')
        layer.append({'laynum':'0', 'layheight':'0', 'z':'0'})
        estory.append('0')        
#循环读入
        while True:
            line=fcg.readline()
#            print(line)
#若结尾则退出            
            if not line:
                break
#如果读到层高信息标记，则开始读层高
            if line.find('层高')>0 and line.find('累计高度')>0:
#跳过2个无用行
                line=fcg.readline()
                line=fcg.readline()
                #开始循环读入层高
                while True:
                    line=fcg.readline()
                    #空行则结束                
                    if not line.strip():
                        break
                    info=",".join(line.split()) 
                    #print(info)
                    info=",".join(info.split('('))        
                    #print(info)             
                    info=info.split(',')
                    layer.append({'laynum':info[0], 'layheight':info[-2], 'z':info[-1]})
                    estory.append(info[-1])
#                    print(info[0],info[-2], info[-1])


        fcg.close()
        print(estory)
        
#--------------------------------------        
#按照etabs的规则重定义节点编号，增加字段etabsnum
#分为2类：层内的节点和层外的节点，增加字段layin
#如果是层内，则与已编号的层内节点比较x,y平面定位，如果已编号，则取已存在节点的编号
#如果是层外，则与已编号的层外节点比较。
#每取得一个etabsnum编号，则对线、面中的节点进行依次赋予新的节点编号etabi,etabj,etabk,etabl
        etlayinnode=[]
#        etlayinnode.append({'x':-10000, 'y':-10000, 'etabsnum':0})
        etlayounode=[]
#        etlayounode.append({'x':-10000, 'y':-10000, 'etabsnum':0})      
        nodenum=0
        for node in mnode:
#判断面内与否        
            if node['z'] in estory:
                node['layin']='yes'
                #与已有层内节点比较x,y坐标
                index=0
                for etn in etlayinnode:
                    if node['x']==etn['x'] and node['y']==etn['y']:
                        node['etabsnum']=str(etn['etabsnum'])
                        index=1
                #如果没有被编号，则新加编号
                if index==0:
                    etlayinnode.append({'x':node['x'], 'y':node['y'], 'etabsnum':nodenum+1})                    
                    node['etabsnum']=str(etlayinnode[-1]['etabsnum'])
                    nodenum=nodenum+1
                   # print('nodenum=', nodenum)
            else:
                node['layin']='no'
                #与已有层外节点比较x,y坐标
                index=0
                for etn in etlayounode:
                    if node['x']==etn['x'] and node['y']==etn['y']:
                        node['etabsnum']=str(etn['etabsnum'])
                        index=1
                #如果没有被编号，则新加编号
                if index==0:
                    etlayounode.append({'x':node['x'], 'y':node['y'], 'etabsnum':nodenum+1})                    
                    node['etabsnum']=str(etlayounode[-1]['etabsnum'])   
                    nodenum=nodenum+1                    
                    


                  
        f.write('\n')
        f.write('$ STORIES - IN SEQUENCE FROM TOP'+'\n')
        f.write('\n')        
#写入层数据
        storyname=[]
        lst=len(estory)
#        print(lst)
        for i, story in enumerate(estory):
#            print(i)
            if lst-i>1:
               t=lst-i-1
               b=t-1
#               print(t, b)
               f.write('  STORY "STORY'+'{}'.format(t)+'"'+'  HEIGHT '+'{0:.3f}'.format(float(estory[t])-float(estory[b]))+'\n')
        f.write('  STORY "BASE"  ELEV 0')
        f.write('\n')            
        for i, story in enumerate(estory):
            if i==0:
               t=0
               b=0
            else:
               t=i
               b=i-1           
            storyname.append({'z':story, 'name':'STORY'+'{}'.format(t)})
        for a in storyname:
            print(a['z'], a['name'])

        
        f.write('\n')
#写入刚性隔板定义
        f.write('''"$ DIAPHRAGM NAMES
  DIAPHRAGM "D1"    TYPE RIGID'''+'\n')
        f.write('\n')  
#写入材料信息，用etabs的默认数据，可进行修改自重和质量密度
#此处重度设为25，密度设置为2.551，钢筋设置为HRB400级
        f.write('''$ MATERIAL PROPERTIES
 MATERIAL "C15" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 22000000.0000 U 0.2000 A 1E-005
 MATERIAL "C15" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 15000.0000 FYS 235000.0000
 MATERIAL "C20" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 25500000.0000 U 0.2000 A 1E-005
 MATERIAL "C20" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 20000.0000 FYS 235000.0000
 MATERIAL "C25" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 28000000.0000 U 0.2000 A 1E-005
 MATERIAL "C25" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 25000.0000 FYS 235000.0000
 MATERIAL "C30" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 30000000.0000 U 0.2000 A 1E-005
 MATERIAL "C30" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 30000.0000 FYS 235000.0000
 MATERIAL "C35" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 31500000.0000 U 0.2000 A 1E-005
 MATERIAL "C35" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 35000.0000 FYS 235000.0000
 MATERIAL "C40" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 32500000.0000 U 0.2000 A 1E-005
 MATERIAL "C40" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 40000.0000 FYS 235000.0000
 MATERIAL "C45" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 33500000.0000 U 0.2000 A 1E-005
 MATERIAL "C45" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 45000.0000 FYS 235000.0000
 MATERIAL "C50" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 34500000.0000 U 0.2000 A 1E-005
 MATERIAL "C50" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 50000.0000 FYS 235000.0000
 MATERIAL "C55" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 35500000.0000 U 0.2000 A 1E-005
 MATERIAL "C55" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 55000.0000 FYS 235000.0000
 MATERIAL "C60" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 36000000.0000 U 0.2000 A 1E-005
 MATERIAL "C60" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 60000.0000 FYS 235000.0000
 MATERIAL "C65" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 36500000.0000 U 0.2000 A 1E-005
 MATERIAL "C65" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 65000.0000 FYS 235000.0000
 MATERIAL "C70" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 37000000.0000 U 0.2000 A 1E-005
 MATERIAL "C70" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 70000.0000 FYS 235000.0000
 MATERIAL "C75" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 37500000.0000 U 0.2000 A 1E-005
 MATERIAL "C75" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 75000.0000 FYS 235000.0000
 MATERIAL "C80" M 2.5484 W 25.0000 TYPE "ISOTROPIC" E 38000000.0000 U 0.2000 A 1E-005
 MATERIAL "C80" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 80000.0000 FYS 235000.0000
 MATERIAL "FC15" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 22000000.0000 U 0.2000 A 1E-005
 MATERIAL "FC15" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 15000.0000 FYS 235000.0000
 MATERIAL "FC20" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 25500000.0000 U 0.2000 A 1E-005
 MATERIAL "FC20" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 20000.0000 FYS 235000.0000
 MATERIAL "FC25" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 28000000.0000 U 0.2000 A 1E-005
 MATERIAL "FC25" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 25000.0000 FYS 235000.0000
 MATERIAL "FC30" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 30000000.0000 U 0.2000 A 1E-005
 MATERIAL "FC30" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 30000.0000 FYS 235000.0000
 MATERIAL "FC35" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 31500000.0000 U 0.2000 A 1E-005
 MATERIAL "FC35" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 35000.0000 FYS 235000.0000
 MATERIAL "FC40" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 32500000.0000 U 0.2000 A 1E-005
 MATERIAL "FC40" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 40000.0000 FYS 235000.0000
 MATERIAL "FC45" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 33500000.0000 U 0.2000 A 1E-005
 MATERIAL "FC45" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 45000.0000 FYS 235000.0000
 MATERIAL "FC50" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 34500000.0000 U 0.2000 A 1E-005
 MATERIAL "FC50" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 50000.0000 FYS 235000.0000
 MATERIAL "FC55" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 35500000.0000 U 0.2000 A 1E-005
 MATERIAL "FC55" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 55000.0000 FYS 235000.0000
 MATERIAL "FC60" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 36000000.0000 U 0.2000 A 1E-005
 MATERIAL "FC60" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 60000.0000 FYS 235000.0000
 MATERIAL "FC65" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 36500000.0000 U 0.2000 A 1E-005
 MATERIAL "FC65" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 65000.0000 FYS 235000.0000
 MATERIAL "FC70" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 37000000.0000 U 0.2000 A 1E-005
 MATERIAL "FC70" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 70000.0000 FYS 235000.0000
 MATERIAL "FC75" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 37500000.0000 U 0.2000 A 1E-005
 MATERIAL "FC75" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 75000.0000 FYS 235000.0000
 MATERIAL "FC80" M 0.0000 W 0.0000 TYPE "ISOTROPIC" E 38000000.0000 U 0.2000 A 1E-005
 MATERIAL "FC80" DESIGNTYPE "CONCRETE" FY 400000.0000 FC 80000.0000 FYS 235000.0000
 MATERIAL "Q235" M 7.9511 W 78.0000 TYPE "ISOTROPIC" E 206000000.0000 U 0.3040 A 1.2E-005
 MATERIAL "Q235" DESIGNTYPE "STEEL" FY 235000.0000 FU 373750.0000 PRICE 1
 MATERIAL "Q345" M 7.9511 W 78.0000 TYPE "ISOTROPIC" E 206000000.0000 U 0.3040 A 1.2E-005
 MATERIAL "Q345" DESIGNTYPE "STEEL" FY 335000.0000 FU 469999.9688 PRICE 1
 MATERIAL "Q390" M 7.9511 W 78.0000 TYPE "ISOTROPIC" E 206000000.0000 U 0.3040 A 1.2E-005
 MATERIAL "Q390" DESIGNTYPE "STEEL" FY 390000.0000 FU 487624.9688 PRICE 1
 MATERIAL "Q420" M 7.9511 W 78.0000 TYPE "ISOTROPIC" E 206000000.0000 U 0.3040 A 1.2E-005
 MATERIAL "Q420" DESIGNTYPE "STEEL" FY 420000.0000 FU 516999.9688 PRICE 1 '''+'\n')
        f.write('\n')  
 #写入梁截面定义，按矩形截面、圆形截面、钢管柱顺序定义
 #midas中截面跟材料是分开定义的，在etabs是截面定义中指明了材料。
 #给每个单元增加一个字段：etabs截面名，不水平杆为柱，水平杆为梁，再增加一个层字段
        for ele in mele:
            if(ele['eletype']=='BEAM'):
                for mt in mmat:
                    if ele['elemat']==mt['matnum']:
                        matname=mt['matname']     
                        ele['elematname']=matname

                for msec in msection:
                    if ele['elesection']==msec['snum']:
                        secname=msec['sname']      
                        if msec['sectiontype']=='Rectangular':
                            ele['sectiontype']='Rectangular'
                            ele['D']=msec['sh']
                            ele['B']=msec['sb']
                        if msec['sectiontype']=='Circle':
                            ele['sectiontype']='Circle'
                            ele['sr']=msec['sr']
                        if msec['sectiontype']=='GangGuanZhu':
                            ele['sectiontype']='GangGuanZhu'
                            ele['sr']=msec['sr']
                            ele['st']=msec['st']
                            for mt in mmat:                            
                                if ele['elemat']==mt['matnum']:
                                    ele['steel']=mt['steel']     
                                    ele['conc']=mt['conc']
                i=ele['eleI']
                j=ele['eleJ']
#                print(i, j)
                for node in mnode:
                    if node['nnum']==i:
                        zi=float(node['z'])
                    if node['nnum']==j:
                        zj=float(node['z'])
                if abs(zi-zj)<= 1e-2:                
                    ele['etabssectionname']='Beam'+matname+secname
                else:    
                    ele['etabssectionname']='Col'+matname+secname
                for z in storyname:
                    if abs(float(z['z'])-zj)<=1e-3:
                        ele['story']=z['name']
                #print(ele['elenum'], ele['story'])        
#水平为板PLATE(三角形)，不水平为WALL(四边形),分别处理                   
        for ele in mele:
            for mt in mmat:
                if ele['elemat']==mt['matnum']:
                    matname=mt['matname']    
                    ele['matname']=matname                    
                    
            if(ele['eletype']=='WALL'):        
                for mtk in mthick:
                    if ele['elesection']==mtk['thicknum']:
                        secname=mtk['thickness']                
                    ele['etabssectionname']='Wall'+matname+'-'+secname
                    ele['thickname']=secname
                k=ele['eleK']
                for node in mnode:
                    if node['nnum']==k:
                        zk=node['z']                       
                for z in storyname:
                    if abs(float(z['z'])-float(zk))<=1e-3:
                        ele['story']=z['name']
                        
            if(ele['eletype']=='PLATE'):      
                for mtk in mthick:
                    if ele['elesection']==mtk['thicknum']:
                        secname=mtk['thickness']                
                    ele['etabssectionname']='Plate'+matname+'-'+secname
                    ele['thickname']=secname  
                k=ele['eleK']
                for node in mnode:
                    if node['nnum']==k:
                        zk=node['z']                       
                for z in storyname:
                    if abs(float(z['z'])-float(zk))<=1e-3:
                        ele['story']=z['name']                    
#                print(ele['etabssectionname'])
#给每个单元增加12个字段：释放p,v2,v3,m2,m3，对IJ端分别增加，默认是空白，释放时分别为PI,V2I,V3I,TI，M2I,M3I，PJ,V2J,V3J,TJ,M2J,M3J，默认是空白，再添加一个release字段综合释放信息
        for ele in mele:
            if(ele['eletype']=='BEAM'):
                ele['PI']=''
                ele['PJ']=''
                ele['V2I']=''
                ele['V2J']=''
                ele['V3I']=''
                ele['V3J']=''
                ele['TI']=''
                ele['TJ']=''
                ele['M2I']=''
                ele['M2J']=''
                ele['M3I']=''
                ele['M3J']=''
        for rele in mframerelease:
            elem=rele['elenum']
            for ele in mele:
                if ele['elenum']==elem:
                    if rele['fxi']=='1':
                        ele['PI']='PI'
                    if rele['fyi']=='1':
                        ele['V2I']='V2I'
                    if rele['fzi']=='1':
                        ele['V3I']='V3I'
                    if rele['mxi']=='1':       
                        ele['TI']='TI'
                    if rele['myi']=='1':      
                        ele['M2I']='M2I'
                    if rele['mzi']=='1':      
                        ele['M3I']='M3I'
                        
                    if rele['fxj']=='1':
                        ele['PJ']='PJ'
                    if rele['fyj']=='1':
                        ele['V2J']='V2J'
                    if rele['fzj']=='1':
                        ele['V3J']='V3J'
                    if rele['mxj']=='1':       
                        ele['TJ']='TJ'
                    if rele['myj']=='1':      
                        ele['M2J']='M2J'
                    if rele['mzj']=='1':      
                        ele['M3J']='M3J'  
        for ele in mele:
            if(ele['eletype']=='BEAM'):
                ele['release']=''
                info=(ele['PI'], ele['PJ'], ele['V2I'], ele['V2J'], ele['V3I'], ele['V3J'], ele['TI'], ele['TJ'], ele['M2I'], ele['M2J'], ele['M3I'], ele['M3J'])
                rel=' '.join(info)
                rel=rel.strip().replace('   ', ' ').replace('  ', ' ')
                if rel.find('I')>=0 or rel.find('J')>=0:
                    ele['release']='RELEASE "'+rel+'"'
                        
#统计用过的截面
        eadded=[]
        erecbeamsec=[]
        ecirbeamsec=[]
        ereccolsec=[]
        ecircolsec=[]
        eggz=[]
        ewall=[]
        eplate=[]
        for ele in mele:
            ename=ele['etabssectionname']
#            print(ename)
            if ename in eadded:
                continue
            elif ename.find('SB')>=0 and ename.find('Beam')>=0: 
                erecbeamsec.append({'name':ename, 'shape':'Rectangular','matname':ele['elematname'], 'D':ele['D'], 'B':ele['B'] })
                eadded.append(ename)
            elif ename.find('SB')>=0 and ename.find('Col')>=0:
                ereccolsec.append({'name':ename, 'shape':'Rectangular','matname':ele['elematname'], 'D':ele['D'], 'B':ele['B'] })
                eadded.append(ename)                
            elif ename.find('SR')>=0 and ename.find('Beam')>=0:
                ecirbeamsec.append({'name':ename, 'shape':'Circle','matname':ele['elematname'], 'sr':ele['sr']})
                eadded.append(ename)                
            elif ename.find('SR')>=0 and ename.find('Col')>=0:
                ecircolsec.append({'name':ename, 'shape':'Circle','matname':ele['elematname'], 'sr':ele['sr']})      
                eadded.append(ename)              
            elif ename.find('EPC')>=0:
                eggz.append({'name':ename, 'shape':'GangGuanZhu','matname':ele['elematname'], 'sr':ele['sr'], 'st':ele['st'], 'steel':ele['steel'], 'conc':ele['conc']})    
                eadded.append(ename)                
            elif ename.find('Wall')>=0:
                ewall.append({'name':ename, 'thickname':ele['thickname'], 'matname':ele['matname']})  
                eadded.append(ename)                
            elif ename.find('Plate')>=0:
                ewall.append({'name':ename, 'thickname':ele['thickname'], 'matname':ele['matname']})  
                eadded.append(ename)
#写框架截面            
        f.write('$ FRAME SECTIONS'+'\n')
        for sec in erecbeamsec:
            f.write('  FRAMESECTION  '+'"'+sec['name']+'"'+'  MATERIAL '+'"'+sec['matname']+'"'+' SHAPE "Rectangular" D '+sec['D']+' B '+sec['B']+'\n')
        for sec in ereccolsec:
            f.write('  FRAMESECTION  '+'"'+sec['name']+'"'+'  MATERIAL '+'"'+sec['matname']+'"'+' SHAPE "Rectangular" D '+sec['D']+' B '+sec['B']+'\n')
        for sec in ecirbeamsec:
            f.write('  FRAMESECTION  '+'"'+sec['name']+'"'+'  MATERIAL '+'"'+sec['matname']+'"'+' SHAPE "Circle" D '+sec['sr']+'\n')
        for sec in ecircolsec:
            f.write('  FRAMESECTION  '+'"'+sec['name']+'"'+'  MATERIAL '+'"'+sec['matname']+'"'+' SHAPE "Circle" D '+sec['sr']+'\n')
        for sec in eggz:
            f.write('  FRAMESECTION  '+'"'+sec['name']+'"'+'  MATERIAL '+'"'+sec['matname']+'"'+' SHAPE "SD Section"'+'\n')
        for sec in eggz:
            f.write('  FRAMESECTION  '+'"'+sec['name']+'"'+'  MMOD     '+' 0        '+   ' WMOD 0'+'\n')
        f.write('\n')
#写钢筋定义
        f.write('''$ REBAR DEFINITIONS
  REBARDEFINITION  "6d"  AREA  .0000283  DIA  .006
  REBARDEFINITION  "8d"  AREA  .0000503  DIA  .008
  REBARDEFINITION  "10d"  AREA  .0000785  DIA  .01
  REBARDEFINITION  "12d"  AREA  .000113  DIA  .012
  REBARDEFINITION  "14d"  AREA  .000154  DIA  .014
  REBARDEFINITION  "16d"  AREA  .000201  DIA  .016
  REBARDEFINITION  "20d"  AREA  .000314  DIA  .02
  REBARDEFINITION  "25d"  AREA  .000491  DIA  .025
  REBARDEFINITION  "26d"  AREA  .000531  DIA  .026
  REBARDEFINITION  "28d"  AREA  .000616  DIA  .028 ''')
        f.write('\n\n')
        
#写混凝土截面设计信息  
        f.write('$ CONCRETE SECTIONS'+'\n')
        for sec in erecbeamsec:
            f.write('  CONCRETESECTION  "'+sec['name']+'"   ')
            f.write('TYPE "BEAM"  COVERTOP 0.025  COVERBOTTOM 0.025  ATI 0  ABI 0  ATJ 0  ABJ 0'+'\n')
        for sec in ecirbeamsec:
            f.write('  CONCRETESECTION  "'+sec['name']+'"   ')
            f.write('TYPE "BEAM"  COVERTOP 0.025  COVERBOTTOM 0.025  ATI 0  ABI 0  ATJ 0  ABJ 0'+'\n')  
        for sec in ereccolsec:
            f.write('  CONCRETESECTION  "'+sec['name']+'"   ')
            f.write('TYPE "COLUMN"  PATTERN "R-3-3"  TRANSREINF "TIES"  COVER 0.035  REBAR "20d"  DESIGNCHECK "DESIGN"'+'\n')           
        for sec in ecircolsec:
            f.write('  CONCRETESECTION  "'+sec['name']+'"   ')
            f.write('TYPE "COLUMN"  PATTERN "C-8"  TRANSREINF "TIES"  COVER 0.035  REBAR "25d"  DESIGNCHECK "DESIGN"'+'\n')    
#写钢管柱设计截面
        f.write('\n') 
        f.write('$ SECTION DESIGNER SECTIONS'+'\n')        
        for sec in eggz: 
            f.write('  SDSECTION "'+sec['name']+'"  TYPE "FRAME"  DESIGNTYPE "OTHER"  BASEMATERIAL "'+sec['conc']+'"  NUMSHAPES 2  ANGLE 90'+'\n')
            f.write('  SDSECTION "'+sec['name']+'"  SHAPE 1  MATERIAL "'+sec['conc']+'"  SHAPETYPE "CIRCLE"  D '+str(float(sec['sr'])-2*float(sec['st']))+'  XC 0  YC 0'+'\n')
            f.write('  SDSECTION "'+sec['name']+'"  SHAPE 2  MATERIAL "'+sec['steel']+'"  SHAPETYPE "PIPE"  D '+sec['sr']+'  T '+sec['st']+'  XC 0  YC 0'+'\n')
#写墙和板截面            
        f.write('\n') 
        f.write('$ WALL/SLAB/DECK PROPERTIES'+'\n')        
        for sec in ewall:             
            f.write('  SHELLPROP  "'+(sec['name']+'"').ljust(20)+'  MATERIAL "'+sec['matname']+'"  PROPTYPE "WALL"  TYPE "SHELL"  PLATETYPE "THIN"  TM '+sec['thickname']+'  TB '+sec['thickname']+'\n')
        for sec in eplate:
            f.write('  SHELLPROP  "'+(sec['name']+'"').ljust(20)+'  MATERIAL "'+sec['matname']+'"  PROPTYPE "SLAB"  TYPE "SHELL"  PLATETYPE "THIN"  TM '+sec['thickname']+'  TB '+sec['thickname']+'\n')
#写节点坐标 
        f.write('\n') 
        f.write('$ POINT COORDINATES'+'\n')
        for node in etlayinnode:
            f.write('  POINT "'+str(node['etabsnum'])+'"  '+node['x']+' '+node['y']+'\n')
        for node in etlayounode:
            f.write('  POINT "'+str(node['etabsnum'])+'"  '+node['x']+' '+node['y']+'\n')            
#写线
        f.write('\n') 
        f.write('$ LINE CONNECTIVITIES'+'\n')
        for ele in mele:
#            print(ele['etabssectionname'])
            if ele['etabssectionname'].find('Col')>=0:
                for node in mnode:
                    if ele['eleI']==node['nnum']:
                        inum=node['etabsnum']
                    if ele['eleJ']==node['nnum']:
                        jnum=node['etabsnum']
                if inum==jnum:
                    f.write('  LINE  "'+ele['elenum']+'"  COLUMN  "'+inum+'"  "'+jnum+'"  1'+'\n')  
                else:
                    f.write('  LINE  "'+ele['elenum']+'"  COLUMN  "'+inum+'"  "'+jnum+'"  0'+'\n')                     
            if ele['etabssectionname'].find('Beam')>=0:
                for node in mnode:
                    if ele['eleI']==node['nnum']:
                        inum=node['etabsnum']
                    if ele['eleJ']==node['nnum']:
                        jnum=node['etabsnum']                
                f.write('  LINE  "'+ele['elenum']+'"  BEAM    "'+inum+'"  "'+jnum+'"  0'+'\n')  
#写面
        f.write('\n') 
        f.write('$ AREA CONNECTIVITIES'+'\n')                
        for ele in mele:
            if ele['etabssectionname'].find('Wall')>=0:
                for node in mnode:
                    if ele['eleI']==node['nnum']:
                        inum=node['etabsnum']
                    if ele['eleJ']==node['nnum']:
                        jnum=node['etabsnum']         
                    if ele['eleK']==node['nnum']:
                        knum=node['etabsnum']   
                    if ele['eleL']==node['nnum']:
                        lnum=node['etabsnum']     
                i=' 0 '
                j=' 0 '
                k=' 0 '
                L=' 0 '
                if inum==jnum or inum==knum or inum ==lnum:
                    i=' 1 '
                if jnum==knum or jnum==lnum:
                    j=' 1 '                    
                if knum==lnum:
                    k=' 1 '    

                f.write('  AREA "'+ele['elenum']+'"  PANEL  4  "'+inum+'"  "'+jnum+'"  "'+knum+'"  "'+lnum+'"  '+i+j+k+L+'\n')
            if ele['etabssectionname'].find('Plate')>=0:
                for node in mnode:
                    if ele['eleI']==node['nnum']:
                        inum=node['etabsnum']
                    if ele['eleJ']==node['nnum']:
                        jnum=node['etabsnum']         
                    if ele['eleK']==node['nnum']:
                        knum=node['etabsnum']  
 #                   if ele['eleL']==node['nnum']:
 #                       lnum=node['etabsnum']                            
                i=' 0 '
                j=' 0 '
                k=' 0 '
                L=' 0 '
                if inum==jnum or inum==knum :
                    i=' 1 '
                if jnum==knum :
                    j=' 1 '                    


                f.write('  AREA "'+ele['elenum']+'"  FLOOR  3  "'+inum+'"  "'+jnum+'"  "'+knum+'"  '+i+j+k+'\n')
#写线指定
        f.write('\n') 
        f.write('$ LINE ASSIGNS'+'\n')   
        for ele in mele:
            if ele['etabssectionname'].find('Beam')>=0:
                f.write('  LINEASSIGN  "'+ele['elenum']+'"  "'+ele['story']+'"  SECTION "'+ele['etabssectionname']+'"  ANG  0  MAXSTASPC 0.5  '+ele['release']+' CARDINALPT 8    MESH "POINTSANDLINES" '+'\n')
            if ele['etabssectionname'].find('Col')>=0:
                f.write('  LINEASSIGN  "'+ele['elenum']+'"  "'+ele['story']+'"  SECTION "'+ele['etabssectionname']+'"  ANG  0  MINNUMSTA 3'+ele['release']+'  MESH "POINTSANDLINES"  '+'\n')
#写面指定
        f.write('\n') 
        f.write('$ AREA ASSIGNS'+'\n')  
        for ele in mele:
            if ele['etabssectionname'].find('Wall')>=0 or ele['etabssectionname'].find('Plate')>=0:
                f.write('  AREAASSIGN  "'+ele['elenum']+'"  "'+ele['story']+'"  SECTION "'+ele['etabssectionname']+'"  OBJMESHTYPE "DEFAULT"'+'\n')
#写荷载工况
        f.write('\n') 
        f.write('$ STATIC LOADS'+'\n')  
        for case in mstldcase:
            if case['casetype']=='D':
                f.write('  LOADCASE "DL"  TYPE  "DEAD"  SELFWEIGHT  1'+'\n')
            elif case['casetype']=='L':
                f.write('  LOADCASE "LL"  TYPE  "LIVE"  SELFWEIGHT  0'+'\n')     
            else:
                f.write('  LOADCASE "'+case['loadcasename']+'"  TYPE  "OTHER"  SELFWEIGHT  0'+'\n')   
#写线荷载，此处目前只有线分布荷载的定义
        f.write('\n') 
        f.write('$ LINE OBJECT LOADS'+'\n')  
        for load in mstld:       
            if load['loadtarget']=='BEAM':
                bea=load['beamnumber']
                for ele in mele:
                    if ele['elenum']==bea:
                        story=ele['story']
                f.write('  LINELOAD  "'+bea+'"  "'+story+'"  TYPE "UNIFF"  DIR "GRAV"  LC "'+load['loadcasename']+'"  FVAL '+load['ldvalue1']+'\n')
#写面荷载
        f.write('\n') 
        f.write('$ AREA OBJECT LOADS'+'\n')  
        for load in mstld:       
            if load['loadtarget']=='PLATE':
                fac=load['facenumber']
                for ele in mele:
                    if ele['elenum']==fac:
                        story=ele['story']
                f.write('  AREALOAD  "'+fac+'"  "'+story+'"  TYPE "UNIFF"  DIR "GRAV"  LC "'+load['loadcasename']+'"  FVAL '+load['pressurevalue']+'\n')
        f.write('\n')
#写分析选项
        f.write('''$ ANALYSIS OPTIONS
  ACTIVEDOF "UX UY UZ RX RY RZ"  
  DYNAMICS  MODES 12  MODETYPE "EIGEN"  TOL .00001
  MASSOPTIONS  GRAVITY 9.80665  SOURCE "LOADS"  LATERALONLY "YES"    STORYLEVELONLY "YES"  
  MASSOPTIONS  LOAD "DL"  FACTOR 1
  MASSOPTIONS  LOAD "LL"  FACTOR .5''')

  
  
  
  
  
  
  
  
  
  
        f.close()








if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    ui = m2etabs97()
    ui.show()
    sys.exit(app.exec_())
